<template>
	<view>
		<view class="index">
			<view class="tabs">
				<liuyuno-tabs :tabData="tabs" :defaultIndex="defaultIndex" @tabClick='tabClick' />
			</view>

			<block>
			<view class="input-row"
				  style="display: flex;background-color: #FFFFFF;margin: 9px 9px 0 9px ;border-radius: 5px;">
				<view class="input-group" style="display: flex;margin: 8px 15px;width: 100%;">
					<view class="input-row" style="display: flex;">
						<text class="title" style="line-height: 60rpx;">星座：</text>
						<xfl-select :list="namelist" :clearable="false" :showItemNum="5"
									:style_Container="'min-width: 180px;height: 30px'" :placeholder="'请选择'"
									:selectHideType="'hideAll'" @change="changeName">
							{{this.name}}
						</xfl-select>
					</view>
				</view>
			</view>
			</block>
			<block v-if="defaultIndex === 0" v-for="(item, index) in constellatoryList" :key="index">
				<view class="card" style=" color: #FFFFFF;border-radius: 10rpx;background: url(../../static/jnz.jpg);">
					<!--<view class="card" style=" color: #FFFFFF;border-radius: 10rpx;background: url(../../static/{{index}}.jpg);">-->
					<view class="car-title-view" style="margin: 0 20rpx;">
						<view class="width100 row-center" style="font-size: 16px;">
							{{item.name}}
						</view>
						<view class="width100 row-center" style="font-size: 10px;">
							{{item.month}}
						</view>
						<view class="width100" style="text-indent:2em;">
							{{ item.luckInfo}}
						</view>
					</view>
				</view>
			</block>
			<block v-if="defaultIndex === 1" v-for="(item, index) in ciList" :key="index">
				<view class="card">
					<view class="car-title-view" >
							<view class="width100 row-center" style="font-size: 16px;">
								{{item.name}}
							</view>
							<view class="width100 row-center" style="font-size: 12px;">
								{{item.creator}}
							</view>
							<view class="width100 row-center" >
								{{item.context}}
							</view>
					</view>
				</view>
			</block>
			<block v-if="defaultIndex === 2" v-for="(item, index) in ciSongList" :key="index">
				<view class="card">
					<view class="car-title-view" >
							<view class="width100 row-center"  style="font-size: 16px;">
								{{item.name}}
							</view>
							<view class="width100 row-center"  style="font-size: 12px;">
								{{item.creator}}
							</view>
							<view class="width100 row-center">
								{{item.context}}
							</view>
					</view>
				</view>
			</block>
		</view>
	</view>
</template>
<script>
	import wybTable from '@/components/wyb-table/wyb-table.vue'
	import liuyunoTabs from '@/components/liuyuno-tabs/liuyuno-tabs.vue';
	import util, {
		parGetData,
		parSetData,
		checklogin
	} from '../../common/util';
	export default {
		data() {
			return {
				constellatoryList: [], // 星座运势
                namelist: [{
                    value: '金牛座',
                    type: '金牛座'
                },
                    {
                        value: '双子座',
                        type: '双子座'
                    }
                ],
				ciList: [], // 诗词
				ciSongList: [], // 最美宋词
				tabs: ['星座运势', '诗词', '最美宋词'],
				defaultIndex: 0
			};
		},
		components: {
			wybTable,
			liuyunoTabs
		},

		created() {
			this.getConstellatory();
			this.getCiSong();
			this.getCi();
		},
		methods: {
			tabClick(index) {
				this.defaultIndex = index;
			},
            changeName(value) {
                this.name = value.orignItem.type;
                this.getConstellatory();
			},
			getConstellatory() {
				var self = this;
				uni.request({
					url: util.apiurl + 'generator/constellatory/list',
					method: 'POST',
					dataType: 'json',
					data: {
						pageSize:20,
						name:self.name
					},
					success: function(ret) {
						if (ret.data.code == 200) {
							self.constellatoryList = ret.data.data.list;
						}
					},
					fail: res => {
						console.log(JSON.stringify(res));
						uni.showToast({
							title: '请求数据失败请重试',
							duration: 2000,
							icon: 'none'
						});
					}
				});
			},
			getCi() {
				var self = this;
				uni.request({
					url: util.apiurl + 'generator/ci/list',
					method: 'POST',
					dataType: 'json',
					data: {
						pageSize: 9999
					},
					success: function(ret) {
						if (ret.data.code == 200) {
							self.ciList = ret.data.data.list;
						}
					},
					fail: res => {
						console.log(JSON.stringify(res));
						uni.showToast({
							title: '请求数据失败请重试',
							duration: 2000,
							icon: 'none'
						});
					}
				});
			},
			getCiSong() {
				var self = this;
				uni.request({
					url: util.apiurl + 'generator/cisong/list',
					method: 'POST',
					dataType: 'json',
					data: {
						pageSize: 9999
					},
					success: function(ret) {
						if (ret.data.code == 200) {
							self.ciSongList = ret.data.data.list;
						}
					},
					fail: res => {
						console.log(JSON.stringify(res));
						uni.showToast({
							title: '请求数据失败请重试',
							duration: 2000,
							icon: 'none'
						});
					}
				});
			}
		}
	};
</script>

<style>
	.wyb-table-box,
	.wyb-table-content,
	.wyb-table-scroll-view {
		display: block;
	}

	.family-add-btn {
		width: 60%;
		height: 60rpx;
		font-size: 34rpx;
		margin: 45rpx;
		line-height: 60rpx;
	}

	.popup-add-title {
		width: 100%;
		text-align: center;
		display: block;
		font-size: 40rpx;
		margin: 20rpx 0;
	}

	.iconfont {
		font-size: 36rpx !important;
	}

	.width100 {
		width: 100% !important;
	}
	.row-center {
		text-align: center;
	}

	.reply-btn {
		width: 50%;
		height: 70rpx;
		font-size: 32rpx;
		margin: 15rpx;
	}
</style>
